package com.chencong.online.function;

import com.chencong.online.bean.MarketingUserBehaviorBean;
import org.apache.flink.api.common.functions.AggregateFunction;

/**
 * @program: user-behavior-analysis-online
 * @ClassName AppCountAggFunc
 * @description:统计当前窗口数量（累加器）
 * @author: chencong
 * @create: 2021-12-29 10:34
 **/
public class AppCountAggFunc implements AggregateFunction<MarketingUserBehaviorBean, Long, Long> {
    @Override
    public Long createAccumulator() {
        return 0L;
    }

    @Override
    public Long add(MarketingUserBehaviorBean value, Long accumulator) {
        return accumulator + 1;
    }

    @Override
    public Long getResult(Long accumulator) {
        return accumulator;
    }

    @Override
    public Long merge(Long a, Long b) {
        return a + b;
    }
}
